package lock;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class ReadWriteLockTest {
    public static void main(String[] args)
        throws InterruptedException {
        ReentrantLock lock = new ReentrantLock();

        Condition condition = lock.newCondition();
        new Thread(() -> {
            lock.lock();
            System.out.println("read lock");
            try {
                condition.await();
            }
            catch (InterruptedException e) {
                e.printStackTrace();
            }
            finally {
                lock.unlock();
                System.out.println("unlock..");
            }
        }).start();
        Thread.sleep(1000);
        condition.notify();
        System.out.println("end");

    }
}
